<template>
    <div class="screen-container">
        <!-- 数据大屏展示内容区域 -->
        <div class="screen-content" ref="screenRef">
            <div class="top">
                <Top />
            </div>
            <div class="bottom">
                <div class="left">左侧</div>
                <div class="center">中间</div>
                <div class="right">右侧</div>
            </div>
        </div>
    </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'
import Top from './components/top/index.vue'
// 获取展示数据大屏的dom元素
let screenRef = ref()
onMounted(() => {
    screenRef.value.style.transform = `scale(${getScale()}) translate(-50%,-50%)`
})
// 定义大屏的缩放比例
function getScale(w = 1920, h = 1080) {
    const ww = window.innerWidth / w
    const wh = window.innerHeight / h
    return ww < wh ? ww : wh
}
// 监听视口的变化
window.onresize = () => {
    screenRef.value.style.transform = `scale(${getScale()}) translate(-50%,-50%)`
}
</script>

<style lang="less" scoped>
.screen-container {
    height: 100vh;
    width: 100vw;
    background-image: url('./images/bg.png');
    background-repeat: no-repeat;
    background-size: cover;
    .screen-content {
        position: fixed;
        left: 50%;
        top: 50%;
        width: 1920px;
        height: 1080px;
        transform-origin: left top;
        .top {
            width: 100%;
            height: 40px;
        }
        .bottom {
            display: flex;
            .left {
                flex: 1;
            }
            .center {
                flex: 2;
            }
            .right {
                flex: 1;
            }
        }
    }
}
</style>
